package com.platform.service.impl;

import com.platform.dao.OrderDao;
import com.platform.dao.OrderDrawbackDao;
import com.platform.entity.OrderDrawbackEntity;
import com.platform.service.OrderDrawbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 退款申请
Service实现类
 *
 * @author liweihai
 * @email liweihai12345@sina.com
 * @date 2019-04-24 18:03:19
 */
@Service("tOrderDrawbackService")
public class OrderDrawbackServiceImpl implements OrderDrawbackService {
    @Autowired
    private OrderDrawbackDao orderDrawbackDao;
    @Autowired
    private OrderDao orderDao;

    @Override
    public OrderDrawbackEntity queryObject(String orderNo) {
        return orderDrawbackDao.queryObject(orderNo);
    }

    @Override
    public List<OrderDrawbackEntity> queryList(Map<String, Object> map) {
        return orderDrawbackDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return orderDrawbackDao.queryTotal(map);
    }

    @Override
    public int save(OrderDrawbackEntity tOrderDrawback) {
        return orderDrawbackDao.save(tOrderDrawback);
    }

    @Override
    public int update(OrderDrawbackEntity orderDrawback) {

        String orderNo = orderDrawback.getOrderNo();
        Integer orderDrawbackStatu = orderDrawback.getStatu();
        Integer statu = 0;
        if(orderDrawbackStatu == 1){
            statu = 9;
        }else if(orderDrawbackStatu == 2){
            statu = 10;
        }else if(orderDrawbackStatu == 3){
            statu = 11;
        }
        orderDao.updateStatusByDrawback(orderNo,statu);

        return orderDrawbackDao.update(orderDrawback);
    }

    @Override
    public int delete(String orderNo) {
        return orderDrawbackDao.delete(orderNo);
    }

    @Override
    public int deleteBatch(String[] orderNos) {
        return orderDrawbackDao.deleteBatch(orderNos);
    }
}
